package com;

import sun.net.www.protocol.http.HttpURLConnection;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

class ConnectionTest {
    public static void main(String[] args) {
        try {
            URL yahoo = new URL("http://sourceforge.jp/frs/redir.php?m=jaist&f=%2Fskype%2F21999%2Fskype_1.0.zip");

            HttpURLConnection yahooConnection = (HttpURLConnection) yahoo.openConnection();

            int length = yahooConnection.getContentLength();      //in bytes

            System.out.println("length " + length);
            DataInputStream dis = new DataInputStream(yahooConnection.getInputStream());
            String inputLine;



            while ((inputLine = dis.readLine()) != null) {
                System.out.println(inputLine);
            }

            dis.close();
        } catch (MalformedURLException me) {
            System.out.println("MalformedURLException: " + me);
        } catch (IOException ioe) {
            System.out.println("IOException: " + ioe);
        }
    }
}